package com.sali.数据结构;

/**
 旋转数组的最小数字
 */
public class JZ_11 {

    public int minNumberInRotateArray (int[] nums) {
        // write code here
        int leftPoint = 0;
        int rightPoint = nums.length - 1;

        while ( leftPoint < rightPoint ) {
            int midPoint = leftPoint + ( rightPoint - leftPoint ) / 2;
            if ( nums[midPoint] > nums[rightPoint] ) {
                leftPoint = midPoint + 1;
            } else if ( nums[midPoint] < nums[rightPoint] ) {
                rightPoint = midPoint;
            } else {
                rightPoint--;
            }
        }

        return nums[leftPoint];
    }

}
